package com.eian.boot.rabbit.config;

import com.eian.boot.rabbit.core.listener.ConsumerErrorHandler;
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.retry.RejectAndDontRequeueRecoverer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MessageRecovererConfig {

    @Bean
    public MessageRecoverer messageRecoverer() {
        return new RejectAndDontRequeueRecoverer();
    }

    @Bean
    public ConsumerErrorHandler consumerErrorHandler(MessageRecoverer messageRecoverer) {
        return new ConsumerErrorHandler(messageRecoverer);
    }
}